function SailsNgAdmin(option) {
	var _this = this;
	this.admin;
	this.nga;
	
	this.configEntities = function(){
		var tmmenu = _this.nga.entity('tmmenu');
		var fields = [
			_this.nga.field('name'),_this.nga.field('order','number'),
			_this.nga.field('icon'),_this.nga.field('link'),
			_this.nga.field('logo','file').uploadInformation({'url':'/api/file', 'apifilename': 'filename' })
		]
		tmmenu.listView().fields([
		              			_this.nga.field('name'),_this.nga.field('order','number'),
		            			_this.nga.field('icon'),_this.nga.field('link'),
		            			_this.nga.field('logo','template').template('<img src="{{ entry.values.logo }}" width="250">') 
		            		]);
		tmmenu.creationView().fields(fields);
		tmmenu.deletionView().fields(fields);
		_this.admin.addEntity(tmmenu);
	}
	
	this.configMenu = function(){
		_this.admin.menu(_this.nga.menu()
			.addChild(_this.nga.menu(_this.nga.entity('tmmenu')).title('分类菜单').icon('<span class="glyphicon glyphicon-user"></span>'))	
		);
	}
	
	this.init = function() {
		// declare a new module called 'myApp', and make it require the `ng-admin` module as a dependency
		var ngApp = angular.module('tomAdmin', [ 'ng-admin' ]);
		// declare a function to run when the module bootstraps (during the 'config'
		// phase)
		ngApp.config(['NgAdminConfigurationProvider','RestangularProvider',

			function(NgAdminConfigurationProvider,RestangularProvider) {
			
				_this.nga = NgAdminConfigurationProvider;
				
				// create an admin application
				_this.admin = _this.nga.application('TomMall Admin')
				.baseApiUrl(option.basePath + '/api/');
				
				RestangularProvider.addFullRequestInterceptor(
					function(element, operation, what, url, headers, params, httpConfig) {
						if (operation == 'getList') {
							if(params._page && params._perPage){
								params.skip = (params._page - 1) * params._perPage;
								params.limit = params._page * params._perPage;
								delete params._page;
								delete params._perPage;
							}
							if(params._sortField && params._sortDir){
								params.sort = params._sortField + ' ' + params._sortDir;
								delete params._sortField;
								delete params._sortDir;
							}
						}
						//console.log("operation : " + operation);
						console.log("params : " + JSON.stringify(params));
						return { params: params };
					}
				);
				
				_this.configEntities();
				_this.configMenu();
				
				_this.nga.configure(_this.admin);
			}
		]);
	};
	
	this.init();
}